package com.hzdp.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by lyp on 15/12/5.
 */
public class BeanFactory {
    private static BeanFactory ourInstance = new BeanFactory();

    public static BeanFactory getInstance() {
        return ourInstance;
    }

    //TODO????????????
//    private static String[] locations = new String[]{
//            "classpath:config/spring/spring-common.xml",
//            "classpath:config/spring/sqlmap/sqlmap-config.xml"
//    };

    private ApplicationContext context;

    private BeanFactory() {
        String[] locations = new String[]{
                "classpath:config/spring/spring-common.xml",
                "classpath:config/spring/sqlmap/sqlmap-config.xml"
        };
        context = new ClassPathXmlApplicationContext(locations);
    }

    public Object getBean(String name){
        return context.getBean(name);
    }
}
